package game;

import character.MyCharacter;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import player.Player;

public abstract class GameUtil {
    protected static int nextPlayerId = 0;
    protected static int nextCharacterId = 0;

    public static int getNextPlayerId() {
        int toReturn = nextPlayerId;
        nextPlayerId++;
        return toReturn;
    }
    
    public static int getNextCharacterId() {
        int toReturn = nextCharacterId;
        nextCharacterId++;
        return toReturn;
    }
    
    public static Collection<MyCharacter> getAllCharactersInWorld() {
        List<MyCharacter> allCharacters = new LinkedList<MyCharacter>();
        for(Player player : GameController.getAllPlayers())
            allCharacters.addAll(player.getCharacters());
        return allCharacters;
    }
    
    public static Collection<MyCharacter> getAllAICharactersInWorld() {
        List<MyCharacter> allCharacters = new LinkedList<MyCharacter>();
        for(Player player : GameController.getAIPlayers())
            allCharacters.addAll(player.getCharacters());
        return allCharacters;
    }

    /** Returns true if collection contains any of the objects in inner. */
    public static boolean containsAny(Collection<? extends Object> collection, Collection<? extends Object> inner) {
	for(Object innerObject : inner) {
	    if(collection.contains(innerObject))
		return true;
	}
	return false;
    }
}
